Skip to content

fix: don't check for updates in completion subcommand - #609

Merged
SergioGasquez merged 1 commit into
esp-rs:mainfrom
takeshiD:feat/completions-skip-update
Nov 16, 2026
Merged

SergioGasquez merged 1 commit into
esp-rs:mainfrom
takeshiD:feat/completions-skip-update

Conversation

@takeshiD

Copy link
Copy Markdown
Contributor

espup completions always queried crates.io for update before generating completion script.
Add --skip-update (or set ESPUP_SKIP_UPDATE) to skip this check. The default behavior is not changed.

Issue

See #608

@SergioGasquez SergioGasquez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The change works as described: with --skip-update, espup completions zsh goes from ~560 ms to ~9 ms locally, stdout stays clean, and fmt/clippy/tests pass. A few recommendations inline, the main ones being the env var parsing and whether we need a flag at all.

Comment thread src/main.rs Outdated
Comment on lines +42 to +44
if !args.skip_update {
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should completions check for updates at all? It's a non-interactive command whose output gets sourced, and the check is never cached (Duration::ZERO) and uses update-informer's default 5 s timeout, so on a slow/offline network every shell startup can stall for up to 5 s.

Just removing the check_for_update call here would fix #608 for everyone, without the new flag, env var, README and CHANGELOG changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I was worried about backward compatibility, but it doesn't seem to be a real issue here.
I'll just remove the check_for_update call. Thank you for the great review!

Comment thread src/cli.rs Outdated
#[arg(short = 'l', long, default_value = "info", value_parser = ["debug", "info", "warn", "error"])]
pub log_level: String,
/// Skips checking crates.io for a newer version of espup.
#[arg(long, env = "ESPUP_SKIP_UPDATE")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a plain bool + env, clap only accepts true/false:

  • ESPUP_SKIP_UPDATE=1 / yes -> error: invalid value '1' for '--skip-update'
  • ESPUP_SKIP_UPDATE= -> error: a value is required

For the eval "$(espup completions zsh)" use case this produces empty stdout, so completions silently stop working. Since this env var is meant to be exported in rc files, consider:

#[arg(long, env = "ESPUP_SKIP_UPDATE", value_parser = clap::builder::BoolishValueParser::new())]

Also, naming/scope: --skip-update reads like skipping the espup update subcommand; --no-update-check would be clearer. And ESPUP_SKIP_UPDATE sounds global but only completions honors it, while install/update/uninstall still check. Either scope the name or apply it to all subcommands.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I'm removing the check_for_update call (src/main.rs:42-44), the --skip-update flag and the ESPUP_SKIP_UPDATE env var are no longer needed, so I'll remove them.

Comment thread tests/integration.rs Outdated
Comment on lines +16 to +22
#[test]
fn completions_with_skip_update() {
assert_cmd::Command::new(assert_cmd::cargo_bin!("espup"))
.args(["completions", "--skip-update", "bash"])
.assert()
.success();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also passes without the flag, since update-check failures are ignored (.ok().flatten()), so it doesn't verify the check is skipped. Parse tests in src/cli.rs similar to install_accepts_disable_timeouts_flag/_env_var would cover the flag and env var (including "1" if the parser changes).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will be removed too, since the flag no longer exists.

Comment thread CHANGELOG.md Outdated
## [Unreleased]

### Added
- Added `--skip-update` (`ESPUP_SKIP_UPDATE`) to the `completions` subcommand to skip the crates.io version check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: other entries include the PR number, e.g. ... version check (#609).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank, I'll add the PR number.

@takeshiD
takeshiD force-pushed the feat/completions-skip-update branch 2 times, most recently from a508970 to 310687d Compare November 16, 2026 14:24
@takeshiD takeshiD changed the title feat: add --skip-update flag to completions subcommand fix: don't check for updates in completion subcommand Nov 16, 2026
@takeshiD
takeshiD force-pushed the feat/completions-skip-update branch from 310687d to a6f454e Compare November 16, 2026 14:25
@takeshiD

Copy link
Copy Markdown
Contributor Author

@SergioGasquez Thank you for your review. I have removed --skip-update. I also changed feat to fix.

@SergioGasquez SergioGasquez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@SergioGasquez
SergioGasquez merged commit 767aaa5 into esp-rs:main Nov 16, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants